import { userStore } from "@/stores/user";

export default function hasPerm(value: any) {
  const store = userStore();
  const permiss = store.getCodeList;
  if (value && value instanceof Array && value.length > 0) {
    const permissionRoles = value;
    const hasPermission = permiss.some((role) => {
      return permissionRoles.includes(role);
    });
    return hasPermission;
  } else {
    throw new Error("need roles! Like v-permission=\"['admin','editor']\"");
  }
}
